home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MPW C++ / MPW C++ 3.1 / Examples / CPlusExamples / Instructions < prev    next >
Text File  |  1990-09-11  |  10KB  |  253 lines

  1. Instructions - The C++ Examples
  2.  
  3. Copyright Apple Computer, Inc. 1987, 1988
  4. All rights reserved.
  5.  
  6.  
  7. About the Examples
  8.  
  9.     Three sample C++ programs are included with MPW C: two applications,
  10.     and a tool:
  11.     
  12.         CPlusShapesApp - a simple MultiFinder-Aware Sample application
  13.         CPlusTESample  - a simple MultiFinder-Aware TextEdit application 
  14.         Count              - an MPW tool
  15.  
  16.     The source files for each of these examples are in the
  17.     "Examples:CPlusExamples:" folder.  In addition, the makefiles
  18.     containing the commands needed to build each of the
  19.     examples are provided in the same folder.
  20.     
  21.     NOTE:    Due to the larger memory requirements of CFront, you will need
  22.             to set the memory partition of the MPW Shell to at least 2Mb 
  23.             before attempting to build CPlusShapesApp or CPlusTESample.
  24.     
  25.  
  26. Building the Examples
  27.  
  28.     You can easily build each of the sample programs using the Directory
  29.     and Build menus.  (See Chapter 2 of the MPW Reference.)
  30.     
  31.     Set the default directory to "CPlusExamples:"
  32.  
  33.         The simplest way to do this is to execute the following command
  34.         
  35.         Directory "{MPW}"Examples:CPlusExamples:
  36.         
  37.  
  38.     Build the program
  39.     
  40.         You can use any of the four Build items at the bottom of the Build
  41.         menu to build the program you have selected.  Each of these menu
  42.         items displays a dialog box that asks for the name of the program
  43.         you want to build.  When this dialog box appears, type the name of
  44.         one of the sample programs (CPlusShapesApp, CPlusTESample, or Count).
  45.         
  46.         Each of the Build menu items behaves slightly differently:
  47.         
  48.             Build…  -  The program is automatically built.  The commands
  49.             used, and any error messages, are displayed in the Worksheet.
  50.             Only files that have been changed since you last built the
  51.             program are compiled, saving considerable time.
  52.     
  53.             Full Build…  -  The program is completely rebuilt, ignoring
  54.             any object files or intermediate files that may already exist
  55.             from a previous build.  The commands used, and any errors, are
  56.             displayed in the Worksheet.
  57.             
  58.             Show Build Commands…  -  The commands needed to build the program
  59.             are written to the Worksheet, but not executed.  You can then
  60.             select any or all of the commands and execute them yourself.
  61.             (To execute the commands select them and press Enter.)
  62.             
  63.             Show Full Build Commands…  -  The commands needed to completely
  64.             rebuild the program are written to the Worksheet.  This is a
  65.             convenient way to see all of the commands used in building
  66.             the program you have selected.
  67.  
  68.  
  69.    Note: For more information about building the sample programs, see
  70.    Chapter 2 of the MPW Reference.
  71.  
  72.  
  73.  
  74. CPlusShapesApp - A Simple MultiFinder-Aware Sample Application
  75.  
  76.     CPlusShapesApp is an example application that demonstrates how to
  77.     initialize the commonly used toolbox managers, operate successfully
  78.     under MultiFinder, handle desk accessories and draw simple shapes.
  79.     
  80.     CPlusShapesApp is based on a crude application framework comprised in
  81.     the two classes TApplication and TDocument. These classes together
  82.     define a basic framework for Mac applications, without having any
  83.     specific knowledge about the type of data being displayed by the 
  84.     application's documents. They are a (very) crude implementation of 
  85.     the MacApp application model, without the sophisticated view heirarchies
  86.     or any real error handling.
  87.  
  88.         The TApplication class does all of the basic event handling
  89.         and initialization necessary for Mac Toolbox applications.
  90.         It maintains a list of TDocument objects, and passes events
  91.         to the correct TDocument class when apropriate.
  92.     
  93.         The TDocument class does all of the basic document handling
  94.         work. TDocuments are objects that are associated with a
  95.         window. Methods are provided to deal with update, activate,
  96.         mouse-click, key down, and other events. Some additional
  97.         classes which implement a linked list of TDocument objects
  98.         are provided.
  99.     
  100.         The source for the application library is contained in the files
  101.         TApplication.h, TApplicationCommon.h, TApplication.cp, TDocument.h,
  102.         and TDocument.cp. Resource descriptions are contained in the files
  103.         TApplicationCommon.h and TApplication.r.
  104.  
  105.     CPlusShapesApp itself is composed of three classes TShapesApp,
  106.     TShapesDocument and a TShapes hierarchy for drawing the individual
  107.     shapes.
  108.     
  109.         The TShapesApp class is a subclass of TApplication. It
  110.         overrides several TApplication methods, including those
  111.         for handling menu commands and cursor adjustment, and
  112.         it does some necessary initialization.
  113.         
  114.         The TShapesDocument class is a subclass of TDocument. This
  115.         class contains most of the special purpose code for
  116.         shape drawing. In addition to overriding several of the
  117.         TDocument methods, it defines a few additional
  118.         methods which are used by the TShapesApp class to get
  119.         information on the document state.
  120.  
  121.      The source is contained in the files ShapesApp.h, ShapesAppCommon.h,
  122.     ShapesApp.cp, ShapesDocument.h, ShapesDocument.cp, Shapes.h and Shapes.cp.
  123.     Resource descriptions are contained in the files ShapesAppCommon.h and
  124.     ShapesApp.r. The make dependency file is named CPlusShapesApp.make.
  125.  
  126.    To build CPlusShapesApp, simply select the line below and press Enter.
  127.  
  128.         BuildProgram CPlusShapesApp ∑∑ {Worksheet}
  129.  
  130.    To execute CPlusShapesApp, select the line below and press Enter.
  131.  
  132.         CPlusShapesApp
  133.  
  134.  
  135.  
  136. TESample - A Simple MultiFinder-Aware TextEdit Application
  137.  
  138.     CPlusTESample is an example application that demonstrates how to
  139.     initialize the commonly used toolbox managers, operate successfully
  140.     under MultiFinder, handle desk accessories and create, grow, and zoom
  141.     windows. The fundamental TextEdit toolbox calls and TextEdit
  142.     autoscroll are demonstrated. CPlusTESample also shows how to create
  143.     and maintain scrollbar controls.
  144.     
  145.     CPlusTESample is based on a crude application framework comprised in
  146.     the two classes TApplication and TDocument. These classes together
  147.     define a basic framework for Mac applications, without having any
  148.     specific knowledge about the type of data being displayed by the 
  149.     application's documents. They are a (very) crude implementation of 
  150.     the MacApp application model, without the sophisticated view heirarchies
  151.     or any real error handling.
  152.  
  153.         The TApplication class does all of the basic event handling
  154.         and initialization necessary for Mac Toolbox applications.
  155.         It maintains a list of TDocument objects, and passes events
  156.         to the correct TDocument class when apropriate.
  157.     
  158.         The TDocument class does all of the basic document handling
  159.         work. TDocuments are objects that are associated with a
  160.         window. Methods are provided to deal with update, activate,
  161.         mouse-click, key down, and other events. Some additional
  162.         classes which implement a linked list of TDocument objects
  163.         are provided.
  164.     
  165.         The source for the application library is contained in the files
  166.         TApplication.h, TApplicationCommon.h, TApplication.cp, TDocument.h,
  167.         and TDocument.cp. Resource descriptions are contained in the files
  168.         TApplicationCommon.h and TApplication.r.
  169.  
  170.     CPlusTESample itself is composed of three classes TESample,
  171.     and TEDocument, both derived from the application framework classes
  172.     described above.
  173.  
  174.         The TESample class is a subclass of TApplication. It
  175.         overrides several TApplication methods, including those for
  176.         handling menu commands and cursor adjustment, and it does
  177.         some necessary initialization. Note that we only need to
  178.         override
  179.         
  180.         The TEDocument class is a subclass of TDocument. This class
  181.         contains most of the special purpose code for text editing.
  182.         In addition to overriding most of the TDocument methods, it
  183.         defines a number of additional methods which are used by
  184.         the TESample class to get information on the document
  185.         state. 
  186.  
  187.     The source is contained in the files TESample.h, TECommon.h, 
  188.     TESample.cp, TESampleGlue.a, TEDocument.h, and TEDocument.cp.
  189.     Resource descriptions are contained in the files TECommon.h and
  190.     TESample.r. The make dependency file is named CPlusTESample.make.
  191.     
  192.    To build CPlusTESample, simply select the line below and press Enter.
  193.  
  194.         BuildProgram CPlusTESample ∑∑ {Worksheet}
  195.  
  196.    To execute CPlusTESample, select the line below and press Enter.
  197.  
  198.         CPlusTESample
  199.  
  200.  
  201.  
  202. Count - A Sample MPW Tool
  203.  
  204.     Count, a tool that runs in the MPW environment, counts characters and
  205.     lines in files.  A C version of Count is included with MPW, and is
  206.     documented in the MPW Reference, Part II.  The source for Count is in
  207.     the files Count.cp, StreamCounter.h, and StreamCounter.cp and Count.r.
  208.     
  209.     Count is composed of two classes TCountTool and TStreamCounter.
  210.     TCountTool embodies the control flow of the tool, while TStreamCounter
  211.     contains a generic line/character counter for C++ streams.
  212.  
  213.    To build Count, simply select the line below and press Enter.
  214.  
  215.         BuildProgram Count ∑∑ {Worksheet}
  216.  
  217.    To test Count, try counting the characters in file Count.cp.
  218.  
  219.         Count -c Count.cp
  220.  
  221.  
  222.  
  223. Writing Your Own Programs
  224.  
  225.     After building (and perhaps modifying) the sample programs, you will
  226.     undoubtedly want to write a program of your own.  Use the New… item in
  227.     the File menu, to create the source files.  Remember that C language
  228.     source filenames should end in .c.
  229.     
  230.     Create Build Commands…  -  The Create Build Commands… item in the 
  231.     Build menu runs a script that creates a makefile containing the
  232.     commands for building programs written in C, C++, Assembly Language, Pascal, 
  233.     and/or Rez.  Selecting Create Build Commands… displays a dialog box that 
  234.     allows you to enter information about your program.  Type the program's
  235.     name, select its source files by clicking the Files… button, and click
  236.     one of the radio buttons to indicate your choice of an application, tool,
  237.     or desk accessory.  
  238.     
  239.     Create Build Commands… puts the makefile for your program in the file
  240.     <program>.make.  Now you can use the Build menu to build and rebuild
  241.     your program, just as with the examples.
  242.     
  243.     Larger Programs  -  If you add source files as your program grows,
  244.     use Create Build Commands… again to add the new source files to the build
  245.     instructions.  If you out-grow the capabilities of the simple Create
  246.     Build Commands… script (perhaps by using tools other than Asm, C, C++,
  247.     Pascal, Rez, and Link in your builds) you can modify the makefile yourself.
  248.     
  249.     Modifying the Directory and Build Menus  -  The Directory and Build
  250.     menus are both implemented using scripts written in the MPW Shell
  251.     command language.  This has the big advantage that you can modify
  252.     or customize them to match the way you work.
  253.